<?php


namespace Drupal\shushengyuan\Schemas;


use Drupal\shusy_store_order_line\Entity\ShusyStoreOrderLine;

/**
 * @OA\Schema(
 *   schema="AbstractLineItem",
 *   type="object",
 *   description="AbstractLineItem"
 * )
 */
abstract class AbstractLineItem extends AbstractBaseModel {

  final protected function getEntityType() {
    return 'shusy_store_order_line';
  }

  final protected function setValue() {
    if ($this->entity instanceof ShusyStoreOrderLine) {
      $value = [
        /**
         * @OA\Property(
         *   property="lid",
         *   type="int",
         *   description="ID",
         * ),
         */
        'id' => (int) $this->entity->id,
        /**
         * @OA\Property(
         *   property="name",
         *   type="string",
         *   description="产品名",
         * ),
         */
        'name' => (string) $this->getName(),
        /**
         * @OA\Property(
         *   property="standard",
         *   type="string",
         *   description="规格",
         * ),
         */
        'standard' => (string) $this->getStandard(),
        //@todo 前端拼错单词
        'standatd' => (string) $this->getStandard(),
        /**
         * @OA\Property(
         *   property="image",
         *   type="string",
         *   description="封面图",
         * ),
         */
        'image' => (string) $this->getImage(),
        /**
         * @OA\Property(
         *   property="qty",
         *   type="integer",
         *   description="数量",
         * ),
         */
        'qty' => (int) $this->getQty(),
        /**
         * @OA\Property(
         *   property="amount",
         *   type="number",
         *   description="单价",
         * ),
         */
        'amount' => $this->getAmount(),
        /**
         * @OA\Property(
         *   property="total",
         *   type="number",
         *   description="总价",
         * ),
         */
        'total' => $this->getTotal(),
        /**
         * @OA\Property(
         *   property="is_service",
         *   type="integer",
         *   description="是否是服务类产品 0 否 1 是",
         * ),
         */
        'is_service' => (int) $this->getIsService(),
        /**
         * @OA\Property(
         *   property="service",
         *   type="integer",
         *   description="售后状态 0 未申请 1 审核中 2 处理中 3 已完成 4 待补充信息 5 被拒绝",
         * ),
         */
        'service' => $this->getService(),
        /**
         * @OA\Property(
         *   property="serviceLabel",
         *   type="string",
         *   description="售后状态label",
         * ),
         */
        'serviceLabel' => $this->getServiceLabel(),
        /**
         * @OA\Property(
         *   property="desc",
         *   type="string",
         *   description="如果申请被拒绝(5)为拒绝原因",
         * ),
         */
        'desc' => $this->getServiceDesc(),
        'shippings' => $this->getShippings(),
        'coupon' => $this->getCoupon(),
      ];
      $this->merge($value);
    }
  }

  protected function getCoupon() {
    return FALSE;
  }

  protected function getShippings() {
    return [];
  }

  abstract protected function getName();

  abstract protected function getStandard();

  abstract protected function getImage();

  abstract protected function getQty();

  abstract protected function getAmount();

  abstract protected function getTotal();

  abstract protected function getIsService();

  abstract protected function getService();

  abstract protected function getServiceLabel();

  protected function getServiceDesc() {
    return '';
  }


}
